package org.jeecg.modules.sggg.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.sggg.entity.SgGlucoseRecord;
import org.jeecg.modules.sggg.entity.SgMember;
import org.jeecg.modules.sggg.mapper.SgGlucoseRecordMapper;
import org.jeecg.modules.sggg.service.ISgGlucoseRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Description: 血糖记录表
 * @Author: jeecg-boot
 * @Date: 2022-10-17
 * @Version: V1.0
 */
@Service
public class SgGlucoseRecordServiceImpl extends ServiceImpl<SgGlucoseRecordMapper, SgGlucoseRecord> implements ISgGlucoseRecordService {

    @Autowired
    private SgGlucoseRecordMapper sgGlucoseRecordMapper;

    @Override
    public IPage<SgMember> queryPageListBySqlxt(Page<SgMember> page, String sysOrgCode,List<String> responsibleAgencies, Integer day, String roleCode, String userId,String name, String phone,boolean Bindstatus,int deviceType) {
        List<SgMember> cronJobLists = sgGlucoseRecordMapper.queryPageListBySqlxt(page, sysOrgCode,responsibleAgencies, day, roleCode, userId,name,phone,Bindstatus,deviceType);
        return page.setRecords(cronJobLists);
    }

    @Override
    public IPage<SgGlucoseRecord> queryList(Page<SgGlucoseRecord> page, String OrgCode, SgGlucoseRecord sgGlucoseRecord, String roleCode, String userId) {
        return sgGlucoseRecordMapper.queryList(page, OrgCode, sgGlucoseRecord.getMemberId(), sgGlucoseRecord.getMemberName(), sgGlucoseRecord.getMemberPhone(), sgGlucoseRecord.getResponsibleAgencies(),sgGlucoseRecord.getIntervene(), roleCode, userId);
    }

    @Override
    public List<SgGlucoseRecord> getGlucoseRecord(String memberId) {
        return sgGlucoseRecordMapper.getGlucoseRecord(memberId);
    }

    @Override
    public int getGlucoseStatistics(String memberId, Integer level) {
        return sgGlucoseRecordMapper.getGlucoseStatistics(memberId, level);
    }

    @Override
    public SgGlucoseRecord getGlucoseStatisticsByDate(String memberId, String dateStartTime, String dateEndTime) {
        return sgGlucoseRecordMapper.getGlucoseStatisticsByDate(memberId, dateStartTime, dateEndTime);
    }

    @Override
    public Double getGlucoseStatisticsAvg(String memberId, Integer flag) {
        return sgGlucoseRecordMapper.getGlucoseStatisticsAvg(memberId, flag);
    }

    @Override
    public Double getGlucoseStatisticsById(String memberId, Integer phase) {
        return sgGlucoseRecordMapper.getGlucoseStatisticsById(memberId, phase);
    }

    @Override
    public List<Map<String, Object>> interventionWarning(String orgCode) {
        return sgGlucoseRecordMapper.interventionWarning(orgCode);
    }

    @Override
    public List<Map<String, Object>> threeHighNumber(String orgCode) {
        return sgGlucoseRecordMapper.threeHighNumber(orgCode);
    }

    @Override
    public IPage<SgGlucoseRecord> queryListByDoctor(Page<SgGlucoseRecord> page, String name, String phone,List<String> responsibleAgencies, String sysOrgCode, String roleCode, String doctorId, String intervene) {
        return sgGlucoseRecordMapper.queryListByDoctor(page, name, phone,responsibleAgencies, sysOrgCode, roleCode, doctorId, intervene);
    }

    @Override
    public List<SgGlucoseRecord> dayMeasureNumberCount(String sysOrgCode, String roleCode, String date, String doctorId, String intervene,List<String> responsibleAgencies) {
        return sgGlucoseRecordMapper.dayMeasureNumberCount(sysOrgCode, roleCode, date, doctorId, intervene,responsibleAgencies);
    }

    @Override
    public List<SgGlucoseRecord> dayMeasureNumberCountTwo(String sysOrgCode, String roleCode, String date, String doctorId, String intervene,List<String> responsibleAgencies) {
        return sgGlucoseRecordMapper.dayMeasureNumberCountTwo(sysOrgCode, roleCode, date, doctorId, intervene,responsibleAgencies);
    }

    @Override
    public List<Map<String, Integer>> getEachLevelNum(String orgCode) {
        return sgGlucoseRecordMapper.getEachLevelNum(orgCode);
    }
}
